﻿Imports System

Namespace System.Workflow.ComponentModel.Compiler
    <AttributeUsage((AttributeTargets.Interface Or AttributeTargets.Class), AllowMultiple:=False, Inherited:=True)> _
    Public NotInheritable Class ActivityCodeGeneratorAttribute
        Inherits Attribute
        ' Methods
        Public Sub New(ByVal codeGeneratorTypeName As String)
            If (codeGeneratorTypeName Is Nothing) Then
                Throw New ArgumentNullException("codeGeneratorTypeName")
            End If
            Me.codeGeneratorTypeName = codeGeneratorTypeName
        End Sub

        Public Sub New(ByVal codeGeneratorType As Type)
            If (codeGeneratorType Is Nothing) Then
                Throw New ArgumentNullException("codeGeneratorType")
            End If
            If Not GetType(ActivityCodeGenerator).IsAssignableFrom(codeGeneratorType) Then
                Throw New ArgumentException(SR.GetString("Error_NotCodeGeneratorType"), "codeGeneratorType")
            End If
            If (codeGeneratorType.GetConstructor(New Type(0  - 1) {}) Is Nothing) Then
                Throw New ArgumentException(SR.GetString("Error_MissingDefaultConstructor", New Object() { codeGeneratorType.FullName }), "codeGeneratorType")
            End If
            Me.codeGeneratorTypeName = codeGeneratorType.AssemblyQualifiedName
        End Sub


        ' Properties
        Public ReadOnly Property CodeGeneratorTypeName As String
            Get
                Return Me.codeGeneratorTypeName
            End Get
        End Property


        ' Fields
        Private codeGeneratorTypeName As String
    End Class
End Namespace

